home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / a-stwima.ads < prev    next >
Text File  |  1996-01-30  |  6KB  |  179 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                A D A . S T R I N G S . W I D E _ M A P S                 --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.6 $                              --
  10. --                                                                          --
  11. -- This specification is adapted from the Ada Reference Manual for use with --
  12. -- GNAT.  In accordance with the copyright of that document, you can freely --
  13. -- copy and modify this specification,  provided that if you redistribute a --
  14. -- modified version,  any changes that you have made are clearly indicated. --
  15. --                                                                          --
  16. ------------------------------------------------------------------------------
  17.  
  18. package Ada.Strings.Wide_Maps is
  19. pragma Preelaborate (Wide_Maps);
  20.  
  21.    -------------------------------------
  22.    -- Wide Character Set Declarations --
  23.    -------------------------------------
  24.  
  25.    type Wide_Character_Set is private;
  26.    --  Representation for a set of Wide_Character values:
  27.  
  28.    Null_Set : constant Wide_Character_Set;
  29.  
  30.    ------------------------------------------
  31.    -- Constructors for Wide Character Sets --
  32.    ------------------------------------------
  33.  
  34.    type Wide_Character_Range is record
  35.       Low  : Wide_Character;
  36.       High : Wide_Character;
  37.    end record;
  38.    --  Represents Wide_Character range Low .. High
  39.  
  40.    type Wide_Character_Ranges is
  41.      array (Positive range <>) of Wide_Character_Range;
  42.  
  43.    function To_Set
  44.      (Ranges : in Wide_Character_Ranges)
  45.       return   Wide_Character_Set;
  46.  
  47.    function To_Set
  48.      (Span : in Wide_Character_Range)
  49.       return Wide_Character_Set;
  50.  
  51.    function To_Ranges
  52.      (Set :  in Wide_Character_Set)
  53.       return Wide_Character_Ranges;
  54.  
  55.    ---------------------------------------
  56.    -- Operations on Wide Character Sets --
  57.    ---------------------------------------
  58.  
  59.    function "=" (Left, Right : in Wide_Character_Set) return Boolean;
  60.  
  61.    function "not"
  62.      (Right  : in Wide_Character_Set)
  63.       return Wide_Character_Set;
  64.  
  65.    function "and"
  66.      (Left, Right : in Wide_Character_Set)
  67.       return        Wide_Character_Set;
  68.  
  69.    function "or"
  70.      (Left, Right : in Wide_Character_Set)
  71.       return        Wide_Character_Set;
  72.  
  73.    function "xor"
  74.      (Left, Right : in Wide_Character_Set)
  75.       return        Wide_Character_Set;
  76.  
  77.    function "-"
  78.      (Left, Right : in Wide_Character_Set)
  79.       return        Wide_Character_Set;
  80.  
  81.    function Is_In
  82.      (Element : in Wide_Character;
  83.       Set     : in Wide_Character_Set)
  84.       return    Boolean;
  85.  
  86.    function Is_Subset
  87.      (Elements : in Wide_Character_Set;
  88.       Set      : in Wide_Character_Set)
  89.       return     Boolean;
  90.  
  91.    function "<="
  92.      (Left  : in Wide_Character_Set;
  93.       Right : in Wide_Character_Set)
  94.       return  Boolean
  95.    renames Is_Subset;
  96.  
  97.    subtype Wide_Character_Sequence is Wide_String;
  98.    --  Alternative representation for a set of character values
  99.  
  100.    function To_Set
  101.      (Sequence  : in Wide_Character_Sequence)
  102.       return      Wide_Character_Set;
  103.  
  104.    function To_Set
  105.      (Singleton : in Wide_Character)
  106.       return      Wide_Character_Set;
  107.  
  108.    function To_Sequence
  109.      (Set  : in Wide_Character_Set)
  110.       return Wide_Character_Sequence;
  111.  
  112.    -----------------------------------------
  113.    -- Wide Character Mapping Declarations --
  114.    -----------------------------------------
  115.  
  116.    type Wide_Character_Mapping is private;
  117.    --  Representation for a wide character to wide character mapping:
  118.  
  119.    function Value
  120.      (Map     : in Wide_Character_Mapping;
  121.       Element : in Wide_Character)
  122.       return    Wide_Character;
  123.  
  124.    Identity : constant Wide_Character_Mapping;
  125.  
  126.    ---------------------------------
  127.    -- Operations on Wide Mappings --
  128.    ---------------------------------
  129.  
  130.    function To_Mapping
  131.      (From, To : in Wide_Character_Sequence)
  132.       return     Wide_Character_Mapping;
  133.  
  134.    function To_Domain
  135.      (Map  : in Wide_Character_Mapping)
  136.       return Wide_Character_Sequence;
  137.  
  138.    function To_Range
  139.      (Map  : in Wide_Character_Mapping)
  140.       return Wide_Character_Sequence;
  141.  
  142.    type Wide_Character_Mapping_Function is
  143.       access function (From : in Wide_Character) return Wide_Character;
  144.  
  145. private
  146.    type Wide_Character_Set is access Wide_Character_Ranges;
  147.    --  The referenced value satisfies the following constraints:
  148.    --
  149.    --    The lower bound is 1
  150.    --    The ranges are in order by increasing Low values
  151.    --    The ranges are non-overlapping and discontiguous
  152.    --
  153.    --  This representation is chosen to facilitiate the coding of the
  154.    --  Is_In, To_Ranges and logical functions, and is also canonical.
  155.  
  156.    Null_Set : constant Wide_Character_Set :=
  157.                 new Wide_Character_Ranges (1 .. 0);
  158.  
  159.    type Wide_Character_Sequence_Access is access Wide_Character_Sequence;
  160.  
  161.    type Wide_Character_Mapping is record
  162.       Domain : Wide_Character_Sequence_Access;
  163.       Rangev : Wide_Character_Sequence_Access;
  164.    end record;
  165.    --  The two strings are of identical length, and corresponding positions
  166.    --  define the mapping. The characters of From are sorted in ascending
  167.    --  order to facilitate a binary search in the Value function. The lower
  168.    --  bound of each string is always 1. A character that does not appear in
  169.    --  From is mapped to itself, and corresponding character positions in
  170.    --  From and To are always distinct. This representation is canonical.
  171.    --  Note, Domain.all and Rangev.all are exactly the values returned by
  172.    --  the functions To_Domain and To_Range.
  173.  
  174.    Identity : constant Wide_Character_Mapping :=
  175.                 (Domain => new Wide_Character_Sequence'(""),
  176.                  Rangev => new Wide_Character_Sequence'(""));
  177.  
  178. end Ada.Strings.Wide_Maps;
  179.